<HTML><HEAD><TITLE>cardinality(?SetVariable, ?Cardinality)</TITLE>
</HEAD><BODY>[ <A HREF="index.html">library(cardinal)</A> | <A HREF="../../index.html">Reference Manual</A> | <A HREF="../../fullindex.html">Alphabetic Index</A> ]
<H1>cardinality(?SetVariable, ?Cardinality)</H1>
Cardinality of a set
<DL>
<DT><EM>SetVariable</EM></DT>
<DD>A Set (variable or ground).
</DD>
<DT><EM>Cardinality</EM></DT>
<DD>An integer or an FD variable.
</DD>
</DL>
<H2>Description</H2>
Cardinality is the cardinality of SetVariable. If Cardinality is given
		(as an integer or FD variable), then SetVariable is constrained to have such cardinality.
		If Cardinality is a free variable, then it is unified with the set's cardinality as
		an FD variable or an integer (if it is already known).
<H3>Fail Conditions</H3>
Fails if Cardinality can not be the cardinality of SetVariable.
<H3>Resatisfiable</H3>
No.
<H2>Examples</H2>
<PRE>
?- S `::[]..[a,b], cardinality(S,C).
?- S `::[]..[a,b], cardinality(S,1).
?- S `::[]+[a,b]:1, cardinality(S,C).
C = 1

?- cardinality([a,b],C).
C = 2

?- S `::[c]+[a,b]:[1,3], C #&gt; 1, cardinality(S,C).
S = [a,b,c]
C = 3</PRE>
<H2>See Also</H2>
<A HREF="../../lib_public/cardinal/H-2.html"># / 2</A>
</BODY></HTML>
